﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SSCAI.Model
{
    public class FilterData
    {
        private static readonly List<List<string>> dataSource = new List<List<string>> {
                                                                           new List<string>{"147","258","369","789","456","123"},//0
                                                                           new List<string>{"258","369","047","089","567","234"},//1
                                                                           new List<string>{"369","047","158","019","678","345"},//2
                                                                           new List<string>{"047","158","269","012","789","456"},//3
                                                                           new List<string>{"158","269","037","123","089","567"},//4

                                                                           new List<string>{"269","037","148","234","019","678"},//5
                                                                           new List<string>{"037","148","259","345","012","789"},//6
                                                                           new List<string>{"148","259","036","456","123","089"},//7
                                                                           new List<string>{"259","036","147","567","234","019"},//8
                                                                           new List<string>{"036","147","258","678","345","012"}//9
                                                                   };

        public static Dictionary<string, List<string>> FilerDataList = DataList();
        public static Dictionary<string, List<string>> FitlerDataListFD = DataListFD();

        private static Dictionary<string, List<string>> DataList()
        {
            LotteryModel model = new LotteryModel();
            Dictionary<string, List<string>> dict = new Dictionary<string, List<string>>();

            for (int i = 999; i > -1; i--)
            {
                model.WinningNumber = i.ToString("00000");
                var key = i.ToString("000");
                List<string> dataList = new List<string>();

                for (int j = 0; j < 6; j++)
                {
                    for (int a = 0; a < 3; a++)
                    {
                        string strA = dataSource[model.BaiWei][j].Substring(a, 1);
                        for (int b = 0; b < 3; b++)
                        {
                            var strB = strA + dataSource[model.ShiWei][j].Substring(b, 1);
                            for (int c = 0; c < 3; c++)
                            {
                                var strC = strB + dataSource[model.GeWei][j].Substring(c, 1);
                                dataList.Add(strC);
                            }
                        }
                    }

                }

                dict.Add(key, dataList.Distinct().ToList());
            }         

            return dict;
        }

        private static Dictionary<string, List<string>> DataListFD()
        {
            LotteryModel model = new LotteryModel();
            Dictionary<string, List<string>> dict = new Dictionary<string, List<string>>();
            for (int i = 9999; i > -1; i--)
            {
                model.WinningNumber = i.ToString("00000");
                var key = i.ToString("0000");
                List<string> dataList = new List<string>();

                for (int j = 0; j < 6; j++)
                {
                    for (int a = 0; a < 3; a++)
                    {
                        string strA = dataSource[model.QianWei][j].Substring(a, 1);
                        for (int b = 0; b < 3; b++)
                        {
                            var strB = strA + dataSource[model.BaiWei][j].Substring(b, 1);
                            for (int c = 0; c < 3; c++)
                            {
                                var strC = strB + dataSource[model.ShiWei][j].Substring(c, 1);
                                for (int d = 0; d < 3; d++)
                                {
                                    var strD = strC + dataSource[model.GeWei][j].Substring(d, 1);
                                    dataList.Add(strD);
                                }
                            }
                        }
                    }

                }

                dict.Add(key, dataList.Distinct().ToList());
            }
            return dict;
        }
    }
}
